package com.alvis.media.service.impl;

import com.alvis.media.domain.VideoPlay;
import com.alvis.media.repository.MediaBaseMapper;
import com.alvis.media.repository.VideoPlayMapper;
import com.alvis.media.service.VideoPlayService;
import com.alvis.media.utility.DateTimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *@author 奇趣
 */
@Service
public class VideoPlayServiceImpl extends BaseServiceImpl<VideoPlay> implements VideoPlayService
{
    private final VideoPlayMapper videoPlayMapper;

    @Autowired
    public VideoPlayServiceImpl(MediaBaseMapper<VideoPlay> baseMapper, VideoPlayMapper videoPlayMapper)
    {
        super(baseMapper);
        this.videoPlayMapper = videoPlayMapper;
    }


    /**
     * 本月最佳影片
     */
    @Override
    public String findBestVideo(VideoPlay videoPlay)
    {
        // 设置时间从当前月的1号开始查询~当前的这一天
        videoPlay.setLastPlayTime(DateTimeUtil.getMonthStartDay());
        return videoPlayMapper.selectUserCount(videoPlay);
    }
}
